var app = getApp();
var ajax = require('../../utils/ajax.js');
var util = require('../../utils/util.js');
var wxUtil = require('../../utils/wxUtil.js');
var shopInfo = require('../../components/shopInfo/index.js');
var common = require('../../utils/common.js');
var MPage = require('../MPage.js');

Page(common.extendPage(MPage, {
    data: {
        aliPay: true,
        commissData: {},
        onOff: true,
        dataLoaded: false,
        fxUrl: '',
        saleUrl: '',
    },
    /**
     * 页面加载
     */
    onLoad: function(options) {

        wx.showShareMenu({
            withShareTicket: true
        })

        this._getQRCode();
    },

    onShow: function() {
        this._getCommission();
    },
    _getCommission: function() {
        var _self = this;
        ajax.P('/openapi/CUser/fxCommiss', {}, function(data) {

            _self.setData({
                commissData: data.result,
                dataLoaded: true
            })

        })
    },
    _getQRCode: function() {
        var _self = this;

        ajax.P('/openapi/CUser/getFenxiaoXcxQrcode', {}, function(data) {
            var {
                fx,
                sale
            } = data.result;

            _self.setData({
                fxUrl: fx,
                saleUrl: sale

            })
        })
    },
    /**
     * 预览图片
     */
    _previewImg: function(evt) {
        var formId = evt.detail.formId;
        wx.previewImage({
            urls: [evt.currentTarget.dataset.url],
        })
        common.submitForm(formId);
    },
    _jump:function(evt){
        common.jump(evt);
    }
}));